
<template>
     <el-input  ref="myInput" :autofocus="autofocus" @blur="blurs" @focus="focuss"  v-if="isPassword=='Y'" show-password v-model="currentValue" placeholder=""  :readonly="readonly" :required="isRequired" :id="id" class='myInput' :style="styles" clearable size="small"  >
     </el-input>
     <el-autocomplete
        ref="myInput" 
        class="inline-input"
        v-model="currentValue"
        :style="styles"
        :fetch-suggestions="querySearch"
        placeholder="请输入内容"
        :trigger-on-focus="false"
      
      v-else-if="isSearch2=='Y'"
    ></el-autocomplete>

    <el-autocomplete
        ref="myInput" 
        class="inline-input"
        v-model="currentValue"
        :style="styles"
        :fetch-suggestions="querySearch"
        placeholder="请输入内容"
        :trigger-on-focus="false"
        @blur="blurs" @focus="focuss"
        @select="handleSelect"
      
      v-else-if="isMapSearch=='Y'"
    >
   
    <template slot-scope="{ item }">
        <div class="name">{{ item.name }}</div>
        <span class="addr">{{ item.address }}</span>
        <div class="children">
            <div v-for="(em,indexs) in item.children" @click="showDetailMap(em)" class="children_item">
                {{ em.name }}
            </div>
        </div>
    </template>
    </el-autocomplete>

    <!--input type='text' v-else/-->
     <el-input ref="myInput"  :autofocus="autofocus"  @focus="focuss"  v-else v-model.lazy="currentValue" placeholder="" @blur="blurs" @clear="clears" :readonly="readonly" :required="isRequired" :id="id" :class='{"myInput":true,"disabled":disableds2}' :style="styleNew" clearable size="small"  >
     </el-input>
</template>
 
<script>
    import filterXSS from "xss"
    export default {
        props:['id','value','isCode','styles','disableds','data','isreadonly','index','isRequired','isPassword','exkey','extype','isSearch','dataField','isSearch2','fontSize','isChange','attribute'],
        //props:["attribute","dataField","index","data","appid","isCode"],
        name: "my-input",
        inject:["setCarMapPointer","setEndCarPointer"],    //接收一个方法
        data(){
            return {
                isFocus:false,
                autofocus:false,
                currentValue:this.value,
                currentValueOld:'',
                disableds2:this.disableds,
                first:'Y',
                first2:'Y',
                pId:"",
                cId:"",
                amtStr:"",
                isreadonlys:"",
                readonly:false,
                styleNew:this.styles,
                readOnlyGroup:"",
                xssOption:{
                    stripIgnoreTagBody:true
                },
                fieldWidth:"60",
                changePostTimer:null,
                searchData:[],
                isMapSearch:"N",
                searchTimer:null
                /*id:"",
                value:"",
                styles:"",
                disableds:"",
                isreadonly:"",
                isRequired:"",
                isPassword:"",
                exkey:"",
                extype:"",
                isSearch:"",
                isSearch2:""*/
            }
        },
        created(){
           
            try{
                if(this.attribute.fieldWidth){
                    this.fieldWidth=this.attribute.fieldWidth
                }
            }catch(e){}
            if(this.fontSize){
                let fontSize="font-size:"+this.fontSize+";";
                this.styleNew=fontSize+this.styleNew;
            }
            try{
                if(this.exkey.readOnlyGroup){//设置指定的用户组只能看不能修改
                    this.readOnlyGroup=this.exkey.readOnlyGroup;
                    let groupName=sessionStorage.getItem("groupName");
                    if(this.readOnlyGroup!=groupName){
                        this.readonly=true;
                    }
                }
            }catch(e){}
            try{
                if(this.exkey&&this.exkey.isMapSearch){
                    this.isMapSearch=this.exkey.isMapSearch;
                }
            }catch(e){}
            /*if(this.attribute.id){
                this.id=this.attribute.id;
            }
            if(this.attribute.value){
                this.id=this.attribute.value;
            }
            
            if(this.attribute.styles){
                this.styles=this.attribute.styles;
            }
            if(this.attribute.isReadOnly){
                this.isreadonly=this.attribute.isReadOnly;
            }
            if(this.attribute.isRequired){
                this.isRequired=this.attribute.isRequired;
            }
            if(this.attribute.exkey){
                this.exkey=this.attribute.exkey;
            }
            if(this.attribute.extype){
                this.extype=this.attribute.extype;
            }
             if(this.attribute.isPassword){
                this.isPassword=this.attribute.isPassword;
            }
             if(this.attribute.isSearch){
                this.isSearch=this.attribute.isSearch;
            }
             if(this.attribute.isSearch2){
                this.isSearch2=this.attribute.isSearch2;
            }
            if(this.attribute.disableds){
                this.disableds=this.attribute.disableds;
            }*/

           
            this.setData();
            try{
                let disabled=this.exkey.disabled;
                let disableds=disabled.split("#");
                let opr=disableds[1];
                let id=disableds[0];
                let vals=disableds[2];
                let val_=this.data[this.pId][id];
               
                if(opr=="等于"&&vals==val_){
                    this.disableds2=true;
                }
                 if(opr=="不等于"&&vals!=val_){
                    this.disableds2=true;
                }
            }catch(e){}
            //根据条件设置只读
            try{
                if(this.exkey.readonlys){
                    let isReadonly_="Y"
                    for(let i=0;i<this.exkey.readonlys.length;i++){
                        let id=this.exkey.readonlys[i].id;
                        let opr=this.exkey.readonlys[i].opr;
                        let vals=this.exkey.readonlys[i].val;
                        let val_=this.data[this.pId][id];
                        if(opr=="等于"&&vals!=val_){
                            //this.isreadonlys="Y";
                            isReadonly_="N"
                        }
                        if(opr=="不等于"&&vals==val_){
                            //this.isreadonlys="Y";
                            isReadonly_="N"
                        }

                    }
                    this.isreadonlys=isReadonly_;
                }
            }catch(e){}
            if(this.isreadonly=="Y"||this.isreadonlys=="Y"){
                this.readonly=true;
            }
            if(this.isreadonly=="Y"||this.isreadonlys=="Y")
                this.disableds2=true;
            try{
                if(this.exkey.amtStr){
                    this.amtStr=this.exkey.amtStr;
                }else{
                    this.amtStr=this.exkey;
                }
            }catch(e){}

           
        },
        mounted(){
            
            try{
                this.$refs.myInput.$parent.$parent.$children[0].$el.style.fontSize=this.fontSize
            }catch(e){}
        },
        methods:{
            focuss(){
                console.log("focusss=======")
                this.isFocus=true;
            },
            focus(){
                this.$refs.myInput.focus();
            },
            checkTel(value){
                var isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
                var isMob=/^[1][3,4,5,7,8,9,6][0-9]{9}$/;
                
                if(isMob.test(value)||isPhone.test(value)){
                    return true;
                }
                else{
                    return false;
                }
            },
            clears(){
                this.currentValue="";
                //alert(this.isSearch)
                if(this.isSearch=="Y"){
                    this.$set(this.data[this.index],"vals","");
                }
                this.$emit("clear","")
            },
            blurs(){
               if(this.extype=="mobile"){
                   if(!this.checkTel(this.currentValue)){
                       this.currentValue="";
                        this.$message.error('请输入正确的电话号码');
                   }
               }
               this.loadMapPointer();
               this.changePosts()
               this.isFocus=false;
               this.$emit("inputBlur","")
            },
            querySearch(queryString, cb) {

                try{
                    if(this.searchTimer){
                        window.clearTimeout(this.searchTimer)
                    }
                }catch(e){}
                this.searchTimer=window.setTimeout(()=>{
                    let url="";
                    let appid="";
                    let params={}
                    
                    let isOk=true;
                    if(this.exkey.searchs){//暂时没用
                        let searchs=this.exkey.searchs;
                        url=searchs.url
                        appid=searchs.appid;
                        params={
                            queryString:queryString
                        }
                        let paramss=searchs.params;
                        if(paramss){
                            paramss.forEach(item=>{
                                let key =item.key;
                                let field=item.field.split(",");
                                let isEmpty=item.isEmpty;
                                let pre=item.pre;
                                let val="";
                                field.forEach(ff=>{
                                    let val_= this.data[pre][ff]
                                    val+=val_;
                                })
                                if(isEmpty=="N"&&!val){
                                    isOk=false;
                                }
                                params[key]=val;
                            })
                        }
                    }else{//有用
                    url=this.exkey.url;
                    appid=this.exkey.appid;
                    params={
                            queryString:queryString,
                            table:this.exkey.table,
                            field:this.exkey.field,
                            fieldId:this.exkey.fieldId
                        }
                    }
                    
                    if(isOk){
                        this.$post(appid,url,params).then(data=>{
                        
                            this.searchData=data;
                            cb(data);
                        }); 
                    }
                },1500)
                
                
               
            },
            handleSelect(items){
                console.log(items,"itemss==============")
                if(this.exkey.searchs&&this.exkey.searchs.setData){
                    let setDatas=this.exkey.searchs.setData;
                    setDatas.forEach(item=>{
                        let pre=item.pre;
                        let field=item.field;
                        let key=item.key.split(",");
                        let spe=item.spe;

                        if(!spe){
                            spe="";
                        }
                        
                        let val="";
                        for(let h=0;h<key.length;h++){
                            val=val=="" ? items[key[h]]:val+spe+items[key[h]];
                        }
                        console.log("pre------"+pre+"=="+field+"=="+val)
                        this.$set(this.data[pre],field,val)
                    })
                    if(this.exkey.searchs.currenValue)
                        this.currentValue=items[this.exkey.searchs.currenValue];
                    this.loadMapPointer();
                }
            },
            showDetailMap(items){
               
                let url="";
                let appid="";
                let params={}
                
                let isOk=true;
                let setDatas=[];
                if(this.exkey.searchDetail){//暂时没用
                    let searchs=this.exkey.searchDetail;
                    setDatas=searchs.setData;
                    url=searchs.url
                    
                    appid=searchs.appid;
                    params={
                       
                    }
                    let paramss=searchs.params;
                    if(paramss){
                        paramss.forEach(item=>{
                            let key =item.key;
                            let field=item.field.split(",");
                            let isEmpty=item.isEmpty;
                            let val="";
                            field.forEach(ff=>{
                                let val_= items[ff]
                                val+=val_;
                            })
                            if(isEmpty=="N"&&!val){
                                isOk=false;
                            }
                            params[key]=val;
                        })
                    }
                }
               
                if(isOk){
                    this.$post(appid,url,params).then(data=>{
                        setDatas.forEach(item=>{
                            let pre=item.pre;
                            let field=item.field;
                            let key=item.key.split(",");
                            let spe=item.spe;

                            if(!spe){
                                spe="";
                            }
                            
                            let val="";
                            for(let h=0;h<key.length;h++){
                                val=val=="" ? data[key[h]]:val+spe+data[key[h]];
                            }
                            this.$set(this.data[pre],field,val)
                        })

                        
                       
                    }); 
                }

            },
            setData(){
                if(this.isSearch!="Y"){
                    if(!this.value){
                        if(this.data){
                            let ids=this.id.split(".");
                            if(ids.length>1){
                                let p=ids[0];
                                let id_=ids[1];
                                this.pId=p;
                                this.cId=id_;
                                if(this.index||this.index=='0'){
                                    try{
                                        this.currentValue=unescape(this.data[p][this.index][id_]);
                                    }catch(e){}
                                }else{
                                  //  try{
                                     
                                        this.currentValue=unescape(this.data[p][id_]);
                                 //   }catch(e){}
                                }
                                
                            }else{
                                 if(this.dataField){
                                    if(this.data[this.dataField][this.index][this.id]!=undefined)
                                        this.currentValue=unescape(this.data[this.dataField][this.index][this.id]);
                                }else{
                                    if(this.data[this.id])
                                        this.currentValue= unescape(this.data[this.id]);
                                }
                                
                            }
                        
                        }
                    }else{
                        
                        let data={};
                        data.id=this.id;
                        data.val=this.value;
                        data.index=this.index;
                        this.$emit('input',JSON.stringify(data));
                    }
                    if(this.first2=="Y"){
                        window.setTimeout(()=>{
                            this.loadMapPointer();
                        },2000)
                        this.first2="N"
                    }
                    
                    
                }else{
                     this.currentValue=unescape(this.data[this.index].vals)
                }
                
                if(this.currentValue==undefined||this.currentValue=="undefined"){
                    this.currentValue="";
                }
               
                
              
            },
            isRealNum(val){
                // isNaN()函数 把空串 空格 以及NUll 按照0来处理 所以先去除，
                　　if(val === "" || val ==null){
                        return false;
                　　}
                if(!isNaN(val)){　　　　
                    　　//对于空数组和只有一个数值成员的数组或全是数字组成的字符串，
                    　　//isNaN返回false，例如：'123'、[]、[2]、['123'],isNaN返回false,
                    //所以如果不需要val包含这些特殊情况，则这个判断改写为if(!isNaN(val) && typeof val === 'number' )
                    　　　 return true; 
                }else{ 
                　　return false; 
                } 

            },
            loadMapPointer(){
                try{
                   
                    if(this.exkey&&this.exkey.startPointer){
                        let pointerField=this.exkey.startPointer.split(".");
                        let pointer=this.data[pointerField[0]][pointerField[1]].split(",");
                        if(this.data[pointerField[0]][pointerField[1]])
                            this.setCarMapPointer(pointer[0],pointer[1],"");
                    }
                    if(this.exkey&&this.exkey.setMapPointer){
                        
                        /*let url=this.exkey.setMapPointer.url;
                        let labels_="";
                        if(this.exkey.setMapPointer.params){
                            let params=this.exkey.setMapPointer.params.split(",");
                            let pre=this.exkey.setMapPointer.pre;
                            for(let h=0;h<params.length;h++){
                                labels_+=this.data[pre][params[h]]
                            }
                        }
                        

                        
                        console.log(this.exkey,"ssss")
                        console.log("exkey=======================sss==labels========="+labels_+"=="+url)
                        if(labels_){
                            this.$post("",url,{"address":labels_}).then(data=>{
                                this.setCarMapPointer(data.lng,data.lat,labels_)
                            })
                        }*/
                        
                        
                        /*this.$post("",url,{"address":labels}).then(data=>{
                            this.setCarMapPointer(data.lng,data.lat,labels)
                        })*/
                    }


                    /*if(this.exkey&&this.exkey.setEndMapPointer){
                        let url=this.exkey.setEndMapPointer.url;
                        let labels_="";
                        if(this.exkey.setEndMapPointer.params){
                            let params=this.exkey.setEndMapPointer.params.split(",");
                            let pre=this.exkey.setEndMapPointer.pre;
                            for(let h=0;h<params.length;h++){
                                labels_+=this.data[pre][params[h]]
                            }
                        }
                        

                        
                        console.log(this.exkey,"ssss")
                        console.log("exkey=======================sss==labels========="+labels_+"=="+url)
                        if(labels_){
                            this.$post("",url,{"address":labels_}).then(data=>{
                                this.setEndCarPointer(data.lng,data.lat,labels_)
                            })
                        }
                        
                        
                       
                    }*/
                }catch(e){}
            },
            changePosts(){
                if(this.exkey&&this.exkey.changePost){
                    let url=this.exkey.changePost.url;
                    let params=this.exkey.changePost.params;
                    let paramss={};
                    let setData=this.exkey.changePost.setData;

                    let isOk=true;
                    params.forEach(item=>{
                        let key =item.key;
                        let field=item.field.split(",");
                        let isEmpty=item.isEmpty;
                        let pre=item.pre;
                        let val="";
                        field.forEach(ff=>{
                        let val_= this.data[pre][ff]
                        val+=val_;
                        })
                        if(isEmpty=="N"&&!val){
                            isOk=false;
                        }
                        paramss[key]=val;
                    })
                    if(isOk){
                        this.$post("",url,paramss).then(data=>{
                            setData.forEach(item=>{
                                let dstField=item.dstField.split(".");
                                let srcField=item.srcField;
                                this.$set(this.data[dstField[0]],dstField[1],data[srcField]);
                            })
                        })
                    }
                }
            }
        },
        computed:{
            dataFields:function(){
                let ids=this.id.split(".");
                if(ids.length>1){
                    this.pId=ids[0];
                    this.cId=ids[1]
                }
                if(this.pId){
                   
                    return this.data[this.pId][this.cId];
                }
                else if(this.dataField){
                    return this.data[this.dataField][this.index];
                }
            }
        },
        watch:{
            currentValue: function (val,oldVal) { //currentValue值变动就向父组件传值
                if(!val){
                    val="";
                }
                this.currentValue=filterXSS(this.currentValue,this.xssOption);
                this.currentValue=this.currentValue.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/%3C/g,"&lt;").replace(/%3E/g,"&gt;")
                console.log("values======"+this.currentValue)
                if(this.isChange=="Y"){
                    
                    let data={};
                    data.id=this.id;
                    data.val=val;
                    data.index=this.index;
                    this.$emit('input',JSON.stringify(data));
                }
                 if(this.first=='Y'){
                    this.currentValueOld=this.currentValue;
                    this.first='N';
                }
                if(this.isCode=="Y"){
                    this.data["tel"]=val;
                }else if(this.isCode=="S"){
                    this.data["code"]=val;
                }
                if(this.currentValueOld!=this.currentValue){
                    this.GLOBAL.isChange=true
                    if(this.isSearch!="Y"){
                        //console.log(this.exkey.zfamt,"this.exkey.zfamt=====")
                        //给组合支付使用，让组合支付的金额不能大于总金额
                        try{
                          
                            if(this.exkey.zfamt){
                                let id_=this.cId;
                                if(!id_){
                                    id_=this.id;
                                }
                                let zfamt=this.exkey.zfamt.split(",");
                                let hjamt=0;
                                let total=0;
                                let total2=0;
                                if((this.index==0||this.index>0)){
                                    hjamt=Number(this.data[this.dataField][this.index][this.exkey.hjamt]);
                                }else
                                    hjamt=Number(this.data[this.pId][this.exkey.hjamt])

                                
                                for(let i=0;i<zfamt.length;i++){
                                    let amt=0;
                                    
                                    if((this.index==0||this.index>0)){
                                        let data_=this.data[this.dataField][this.index];
                                        amt=Number(data_[zfamt[i]])
                                    }else if(this.dataField){
                                        
                                        amt=Number(this.data[this.dataField][zfamt[i]]);
                                    }else{
                                        amt=Number(this.data[this.pId][zfamt[i]]);
                                    }
                                    
                                    if(zfamt[i]!=id_){
                                        console.log("zfamt==="+zfamt[i]+"=="+id_+"=="+amt)
                                        total+=amt;
                                    }
                                    if(this.exkey.zfamt2){
                                        if(zfamt[i]!=id_&&zfamt[i]!=this.exkey.zfamt2){
                                            total2+=amt;
                                        }
                                    }
                                }
                                console.log(this.exkey.zfamt2,"this.exkey.zfamt2===========")
                                if(this.exkey.zfamt2&&this.exkey.zfamt2!=id_){
                                    //if(hjamt<total+Number(val)){
                                        let amt_=hjamt-total2-Number(val);
                                        console.log("hjamt======="+hjamt+"="+total+"="+total2+"="+amt_+"="+val+"=="+id_+"=="+this.index+"=="+this.dataField)
                                        console.log("v==="+amt_)
                                        if(amt_>=0){
                                            console.log("进入----------")
                                            if((this.index==0||this.index>0)){
                                                console.log("zfamtindex========")
                                                let data_=this.data[this.dataField][this.index];
                                            
                                                this.$set(this.data[this.dataField][this.index],this.exkey.zfamt2,amt_);
                                                
                                                
                                            }else if(this.dataField){
                                                console.log("zfamdataField========")
                                                if(this.data[this.dataField][zfamt[i]]==""){
                                                    this.$set(this.data[this.dataField],this.exkey.zfamt2,amt_);
                                            
                                                }
                                                
                                            }else{
                                                console.log("zfamtsss===")
                                              //  if(this.data[this.pId][zfamt[i]]==""){
                                                    this.$set(this.data[this.pId],this.exkey.zfamt2,amt_);
                                            
                                             //   }
                                            }
                                        }else{
                                            this.currentValue="0"
                                        }
                                       
                                        
                                    //}
                                }else{
                                    if(hjamt<total+Number(val)){
                                        val=hjamt-total;
                                        this.currentValue=val;
                                    }
                                }
                                
                                if(hjamt==total+Number(val)){
                                     for(let i=0;i<zfamt.length;i++){
                                       
                                        
                                        if((this.index==0||this.index>0)){
                                            let data_=this.data[this.dataField][this.index];
                                            if(data_[zfamt[i]]==""){
                                                this.$set(this.data[this.dataField][this.index],zfamt[i],"0");
                                            }
                                            
                                        }else if(this.dataField){
                                            if(this.data[this.dataField][zfamt[i]]==""){
                                                this.$set(this.data[this.dataField],zfamt[i],"0");
                                          
                                            }
                                            
                                        }else{
                                            if(this.data[this.pId][zfamt[i]]==""){
                                                this.$set(this.data[this.pId],zfamt[i],"0");
                                          
                                            }
                                        }
                                        
                                    }
                                }

                            }
                        }catch(e){}
                       
                        let data={};
                        data.id=this.id;
                        data.val=val;
                        data.index=this.index;
                        //this.$emit('input',JSON.stringify(data));
                        //this.$emit('on-change',JSON.stringify(data));
                       
                        if(this.data){
                            if(this.pId){
                            //  console.log("this.index======"+this.index);
                                if(this.index!=""&&(this.index==0||this.index>0)){
                                    let data_=this.data[this.pId][this.index];
                                    data_[this.cId]=val;
                                    if(this.extype=="amt"){
                                        /*if(!this.isRealNum(val)){
                                            this.currentValue="";
                                        }*/
                                        let exkeys=this.amtStr.split(",");
                                        let val_=Number(val);
                                        let val2_=Number(this.data[this.pId][this.index][exkeys[0]]);
                                        data_[exkeys[1]]=val_*val2_;
                                    }
                                   
                                    /*if(this.extype=="yh"){
                                        let exkeys=this.exkey.split(",");
                                        let val_=Number(val);
                                        for(let i=0;i<exkeys.length;i++){
                                            let val2_=Number(this.data[this.pId][this.index][exkeys[i]]);
                                            data_[exkeys[i]]=val2_-val_;
                                        }
                                        
                                        
                                        
                                    }*/
                                    
                                    
                                    this.$set(this.data[this.pId],this.index,data_)


                                   
                                }else{
                                // console.log("ciDD=D=D=D=D=D=="+this.pId+"=="+this.cId+"="+val);
                                    this.$set(this.data[this.pId],this.cId,val);//给字段赋值
                                   
                                    if(this.extype=="amt"){
                                        /*if(!this.isRealNum(val)){
                                            this.currentValue="";
                                        }*/
                                        let exkeys=this.amtStr.split(",");
                                        
                                        let val_=Number(val);
                                        let val2_=Number(this.data[this.pId][exkeys[0]]);
                                        this.$set(this.data[this.pId],exkeys[1],val_*val2_);
                                    }else if(this.extype=='amtjc'){
                                        let year=this.exkey.year;
                                        let month=this.exkey.month;
                                        let amt__=this.exkey.amt;
                                        let val_=Number(val);
                                        let val2_=Number(this.data[this.pId][year])*12;
                                        let val3_=Number(this.data[this.pId][month]);
                                      
                                        this.$set(this.data[this.pId],amt__,val_*(val2_+val3_));
                                    }
                                   /* if(this.extype=="yh"){
                                        let exkeys=this.exkey.split(",");
                                        console.log("exkeys=========="+this.exkey)
                                        let val_=Number(val);
                                        for(let i=0;i<exkeys.length;i++){
                                            let val2_=Number(this.data[this.pId][exkeys[i]]);
                                            console.log("val2_====="+val2_);
                                            this.$set(this.data[this.pId],exkeys[i],val2_-val_);
                                        }
                                       
                                    }*/

                                    //该方法用于一个字段是其他好几个字段分值相加的结果
                                    //exkey里面就是所有需要计算的字段，用逗号分隔，最后的一个字段，就是需要赋值的字段
                                    if(this.extype=="total_amt"){
                                        let exkeys=this.amtStr.split(",");
                                        let id_=exkeys[exkeys.length-1];
                                        let total_=0;
                                        for(let i=0;i<exkeys.length-1;i++){
                                            let val_=Number(this.data[this.pId][exkeys[i]]);
                                            total_=total_+val_;
                                        }
                                        this.$set(this.data[this.pId],id_,total_);
                                    }
                                }
                                
                                try{
                                    if(this.exkey&&this.exkey.loadData&&this.currentValue){
                                        console.log(this.exkey.loadData,"loadData=====slexkeys===============")
                                        let postUrl=this.exkey.loadData.postUrl;
                                        console.log(postUrl)
                                        let setData=this.exkey.loadData.setData;
                                        let params=this.exkey.loadData.params;
                                        let imgField=this.exkey.loadData.imgField;
                                        let paramss={}; 
                                        let isOks=true;
                                        params.forEach(item => {
                                            let key=item.key;
                                            let val=item.val;
                                            let field=item.field;
                                            let pre=item.pre;
                                            let isEmpty=item.isEmpty;
                                            if(field){
                                                val=this.data[pre][field]
                                            }
                                            if(isEmpty=='N'&&!val){
                                                isOks=false;
                                            }
                                            paramss[key]=val;
                                        });
                                        if(isOks){
                                            console.log(setData,"setData==========================")
                                            this.$post("",postUrl,paramss).then(data=>{
                                                setData.forEach(item=>{
                                                    let field=item.field;
                                                    let pre=item.pre;
                                                    let key=item.key;
                                                    let key_pre=item.key_pre;
                                                    let type=item.type;

                                                    if(type=="all"){
                                                        let data_=null;
                                                        if(key_pre){
                                                            data_=data[key_pre]
                                                        }else{
                                                            data_=data;
                                                        }
                                                        for(let key in data_){
                                                            console.log("key============="+key+"="+pre)
                                                            if(data_[key])
                                                                this.$set(this.data[pre],key,data_[key])
                                                        }
                                                        sessionStorage.setItem("reloadImg","Y")
                                                        sessionStorage.setItem("reloadImgField",imgField)
                                                    }else{
                                                        let val="";
                                                        if(key_pre){
                                                            val=data[key_pre][key]
                                                        }else{
                                                            val=data[key]
                                                        }
                                                        if(val)
                                                            this.$set(this.data[pre],field,val)
                                                    }
                                                    

                                                })
                                            })
                                        }
                                       
                                    }
                                }catch(e){}
                            }else{
                                if(this.dataField){
                                     this.$set(this.data[this.dataField][this.index],this.id,val)
                                     if(this.extype=="yh"){
                                        let exkeys=this.amtStr.split(",");
                                        let val_=Number(val);
                                        let oldval_=Number(oldVal);
                                        for(let i=0;i<exkeys.length;i++){
                                            let val2_=Number(this.data[this.dataField][this.index][exkeys[i]]);
                                            this.$set(this.data[this.dataField][this.index],exkeys[i],val2_+oldval_-val_)
                                            
                                        }
                                        
                                        
                                        
                                    }
                                }else{
                                     if(this.index!=""&&(this.index==0||this.index>0)){
                                        this.$set(this.data[this.index],this.id,val)
                                    }else
                                        this.$set(this.data,this.id,val)
                                }
                               
                            }
                        }else{
                            
                        }
                        
                    }else{
                        
                        this.$set(this.data[this.index],"vals",val);
                    }
                    


                    //改本文本框内容是否需要其他字段的值
                    try{
                        console.log(this.exkey.sets,"logs=========")
                        if(this.exkey.sets){
                            for(let i=0;i<this.exkey.sets.length;i++){
                                let content=this.exkey.sets[i].content;
                                let field=this.exkey.sets[i].field;
                                let vals=this.exkey.sets[i].val;
                                if(val.indexOf(content)!=-1){
                                    console.log(this.pId+"=="+field+"=="+vals,"logs")
                                    this.$set(this.data[this.pId],field,vals);
                                }
                            }
                        }
                    }catch(e){}
                     //{'changePost':{'url':'/bygex/jdzh/countmoney','params':[{'key':'province','field':'zo_ex8','pre':'zo','isEmpty':'N'},{'key':'city','field':'zo_ex9','pre':'zo','isEmpty':'N'},{'key':'Kilometre','field':'zo_ex20','pre':'zo','isEmpty':'N'},{'key':'discountType','field':'zo_ex21','pre':'zo'},{'key':'toll','field':'zo_ex46','pre':'zo'}],'setData':[{'srcField':'money','dstField':'zo.zo_ex23'}]}}
                   // console.log(this.exkey,"this.exkey===changePost=====================")
                    
                    //车子定位使用
                  //  console.log(this.exkey.setMapPointer,"this.exkey.setMapPointer==============")
                   
                    this.currentValueOld=val;
                    //alert(this.isFocus)
                    if(!this.isFocus){
                        this.loadMapPointer();
                        this.changePosts()
                    }


                    
                }
             
              //  cocnsole.log("this.exkey======="+this.extype+"=="+this.exkey);
                
            },
            value:function (val) { //对值进行验证0
                
            },
           dataFields:{
                handler: function (newVal) {
                  
                    this.setData()
                },      
                deep: true    //深度监听
            }
        }
    }
</script>
<style scoped>
    .el-input__inner{
        height:25px;
    }
    input{
        height:25px;
    }
    .el-autocomplete{
        width:100%;
    }
    .disabled >>> .el-input__inner{
        background:#f5f7fa;
    }
    .myInput>>>.el-input__inner{
        padding-right:23px;
    }
    
     .name {
        text-overflow: ellipsis;
        overflow: hidden;
        line-height: 20px;
    }
     .addr {
        font-size: 12px;
        color: #b4b4b4;
    }
    .highlighted .addr {
        color: #ddd;
    }
    .children{
        display:flex;
        flex-direction: row;
    }
    .children_item{
        flex:1;
        margin-left:10px;
        margin-right:10px;
        background:#66b1ff;
        padding:5px;
        text-align:center;
        color:#fff;
        border-radius: 5px;
        cursor: pointer;
    }
</style>
<style>
    .el-autocomplete-suggestion li{
        line-height: normal;
        padding: 5px 10px;
        line-height: 20px !important;
    
    }
</style>